package com.itheima.comment.controller;
import com.itheima.comment.docs.CommentReplyVo;
import com.itheima.comment.dto.CommentRelpyDto;
import com.itheima.comment.dto.CommentReplyLikeDto;
import com.itheima.comment.dto.CommentReplySaveDto;
import com.itheima.comment.pojo.ApCommentReply;
import com.itheima.comment.service.ApCommentReplyService;
import com.itheima.common.pojo.PageInfo;
import com.itheima.common.pojo.Result;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
import com.itheima.core.controller.AbstractCoreController;

/**
* <p>
* APP评论回复信息表 控制器</p>
* @author 作者
* @since 2021-09-01
*/
@RestController
@RequestMapping("/apCommentReply")
public class ApCommentReplyController extends AbstractCoreController<ApCommentReply> {

    private ApCommentReplyService apCommentReplyService;

    //注入
    @Autowired
    public ApCommentReplyController(ApCommentReplyService apCommentReplyService) {
        super(apCommentReplyService);
        this.apCommentReplyService=apCommentReplyService;
    }

    /***
     * 增加评论的回复
     */
    @PostMapping(value = "/saveReply")
    public Result saveReply(@RequestBody CommentReplySaveDto dto){
        apCommentReplyService.saveReply(dto);
        return Result.ok();
    }


    /***
     * 增加评论回复的点赞/取消点赞
     */
    @PostMapping(value = "/replyLike")
    public Result replyLike(@RequestBody CommentReplyLikeDto dto){
        apCommentReplyService.replyLike(dto);
        return Result.ok();
    }


    /***
     * 评论回复列表查询 【评论回复->当前用户是否点赞了】
     *  评论回复列表：1）评论ID          2）当前页     3）每页显示条数
     */
    @PostMapping(value = "/loadCommentReply")
    public Result loadReplyPage(@RequestBody CommentRelpyDto dto){
        //CommentReplyVo
        PageInfo<CommentReplyVo> pageInfo = apCommentReplyService.loadReplyPage(dto);
        return Result.ok(pageInfo);
    }

}

